1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.TreeModelT; 26 27 public import glib.MemorySlice; 28 public import glib.Str; 29 public import glib.c.functions; 30 public import gobject.ObjectG; 31 public import gobject.Signals; 32 public import gobject.Value; 33 public import gtk.TreeIter; 34 public import gtk.TreeModelIF; 35 public import gtk.TreePath; 36 public import gtk.c.functions; 37 public import gtk.c.types; 38 public import std.algorithm; 39 40 41 /** 42 * The tree interface used by GtkTreeView 43 * 44 * The `GtkTreeModel` interface defines a generic tree interface for 45 * use by the `GtkTreeView` widget. It is an abstract interface, and 46 * is designed to be usable with any appropriate data structure. The 47 * programmer just has to implement this interface on their own data 48 * type for it to be viewable by a `GtkTreeView` widget. 49 * 50 * The model is represented as a hierarchical tree of strongly-typed, 51 * columned data. In other words, the model can be seen as a tree where 52 * every node has different values depending on which column is being 53 * queried. The type of data found in a column is determined by using 54 * the GType system (ie. %G_TYPE_INT, %GTK_TYPE_BUTTON, %G_TYPE_POINTER, 55 * etc). The types are homogeneous per column across all nodes. It is 56 * important to note that this interface only provides a way of examining 57 * a model and observing changes. The implementation of each individual 58 * model decides how and if changes are made. 59 * 60 * In order to make life simpler for programmers who do not need to 61 * write their own specialized model, two generic models are provided 62 * — the `GtkTreeStore` and the `GtkListStore`. To use these, the 63 * developer simply pushes data into these models as necessary. These 64 * models provide the data structure as well as all appropriate tree 65 * interfaces. As a result, implementing drag and drop, sorting, and 66 * storing data is trivial. For the vast majority of trees and lists, 67 * these two models are sufficient. 68 * 69 * Models are accessed on a node/column level of granularity. One can 70 * query for the value of a model at a certain node and a certain 71 * column on that node. There are two structures used to reference a 72 * particular node in a model. They are the [struct@Gtk.TreePath] and 73 * the [struct@Gtk.TreeIter] (“iter” is short for iterator). Most of the 74 * interface consists of operations on a [struct@Gtk.TreeIter]. 75 * 76 * A path is essentially a potential node. It is a location on a model 77 * that may or may not actually correspond to a node on a specific 78 * model. A [struct@Gtk.TreePath] can be converted into either an 79 * array of unsigned integers or a string. The string form is a list 80 * of numbers separated by a colon. Each number refers to the offset 81 * at that level. Thus, the path `0` refers to the root 82 * node and the path `2:4` refers to the fifth child of 83 * the third node. 84 * 85 * By contrast, a [struct@Gtk.TreeIter] is a reference to a specific node on 86 * a specific model. It is a generic struct with an integer and three 87 * generic pointers. These are filled in by the model in a model-specific 88 * way. One can convert a path to an iterator by calling 89 * gtk_tree_model_get_iter(). These iterators are the primary way 90 * of accessing a model and are similar to the iterators used by 91 * `GtkTextBuffer`. They are generally statically allocated on the 92 * stack and only used for a short time. The model interface defines 93 * a set of operations using them for navigating the model. 94 * 95 * It is expected that models fill in the iterator with private data. 96 * For example, the `GtkListStore` model, which is internally a simple 97 * linked list, stores a list node in one of the pointers. The 98 * `GtkTreeModel`Sort stores an array and an offset in two of the 99 * pointers. Additionally, there is an integer field. This field is 100 * generally filled with a unique stamp per model. This stamp is for 101 * catching errors resulting from using invalid iterators with a model. 102 * 103 * The lifecycle of an iterator can be a little confusing at first. 104 * Iterators are expected to always be valid for as long as the model 105 * is unchanged (and doesn’t emit a signal). The model is considered 106 * to own all outstanding iterators and nothing needs to be done to 107 * free them from the user’s point of view. Additionally, some models 108 * guarantee that an iterator is valid for as long as the node it refers 109 * to is valid (most notably the `GtkTreeStore` and `GtkListStore`). 110 * Although generally uninteresting, as one always has to allow for 111 * the case where iterators do not persist beyond a signal, some very 112 * important performance enhancements were made in the sort model. 113 * As a result, the %GTK_TREE_MODEL_ITERS_PERSIST flag was added to 114 * indicate this behavior. 115 * 116 * To help show some common operation of a model, some examples are 117 * provided. The first example shows three ways of getting the iter at 118 * the location `3:2:5`. While the first method shown is 119 * easier, the second is much more common, as you often get paths from 120 * callbacks. 121 * 122 * ## Acquiring a `GtkTreeIter` 123 * 124 * ```c 125 * // Three ways of getting the iter pointing to the location 126 * GtkTreePath *path; 127 * GtkTreeIter iter; 128 * GtkTreeIter parent_iter; 129 * 130 * // get the iterator from a string 131 * gtk_tree_model_get_iter_from_string (model, 132 * &iter, 133 * "3:2:5"); 134 * 135 * // get the iterator from a path 136 * path = gtk_tree_path_new_from_string ("3:2:5"); 137 * gtk_tree_model_get_iter (model, &iter, path); 138 * gtk_tree_path_free (path); 139 * 140 * // walk the tree to find the iterator 141 * gtk_tree_model_iter_nth_child (model, &iter, 142 * NULL, 3); 143 * parent_iter = iter; 144 * gtk_tree_model_iter_nth_child (model, &iter, 145 * &parent_iter, 2); 146 * parent_iter = iter; 147 * gtk_tree_model_iter_nth_child (model, &iter, 148 * &parent_iter, 5); 149 * ``` 150 * 151 * This second example shows a quick way of iterating through a list 152 * and getting a string and an integer from each row. The 153 * populate_model() function used below is not 154 * shown, as it is specific to the `GtkListStore`. For information on 155 * how to write such a function, see the `GtkListStore` documentation. 156 * 157 * ## Reading data from a `GtkTreeModel` 158 * 159 * ```c 160 * enum 161 * { 162 * STRING_COLUMN, 163 * INT_COLUMN, 164 * N_COLUMNS 165 * }; 166 * 167 * ... 168 * 169 * GtkTreeModel *list_store; 170 * GtkTreeIter iter; 171 * gboolean valid; 172 * int row_count = 0; 173 * 174 * // make a new list_store 175 * list_store = gtk_list_store_new (N_COLUMNS, 176 * G_TYPE_STRING, 177 * G_TYPE_INT); 178 * 179 * // Fill the list store with data 180 * populate_model (list_store); 181 * 182 * // Get the first iter in the list, check it is valid and walk 183 * // through the list, reading each row. 184 * 185 * valid = gtk_tree_model_get_iter_first (list_store, 186 * &iter); 187 * while (valid) 188 * { 189 * char *str_data; 190 * int int_data; 191 * 192 * // Make sure you terminate calls to gtk_tree_model_get() with a “-1” value 193 * gtk_tree_model_get (list_store, &iter, 194 * STRING_COLUMN, &str_data, 195 * INT_COLUMN, &int_data, 196 * -1); 197 * 198 * // Do something with the data 199 * g_print ("Row %d: (%s,%d)\n", 200 * row_count, str_data, int_data); 201 * g_free (str_data); 202 * 203 * valid = gtk_tree_model_iter_next (list_store, 204 * &iter); 205 * row_count++; 206 * } 207 * ``` 208 * 209 * The `GtkTreeModel` interface contains two methods for reference 210 * counting: gtk_tree_model_ref_node() and gtk_tree_model_unref_node(). 211 * These two methods are optional to implement. The reference counting 212 * is meant as a way for views to let models know when nodes are being 213 * displayed. `GtkTreeView` will take a reference on a node when it is 214 * visible, which means the node is either in the toplevel or expanded. 215 * Being displayed does not mean that the node is currently directly 216 * visible to the user in the viewport. Based on this reference counting 217 * scheme a caching model, for example, can decide whether or not to cache 218 * a node based on the reference count. A file-system based model would 219 * not want to keep the entire file hierarchy in memory, but just the 220 * folders that are currently expanded in every current view. 221 * 222 * When working with reference counting, the following rules must be taken 223 * into account: 224 * 225 * - Never take a reference on a node without owning a reference on its parent. 226 * This means that all parent nodes of a referenced node must be referenced 227 * as well. 228 * 229 * - Outstanding references on a deleted node are not released. This is not 230 * possible because the node has already been deleted by the time the 231 * row-deleted signal is received. 232 * 233 * - Models are not obligated to emit a signal on rows of which none of its 234 * siblings are referenced. To phrase this differently, signals are only 235 * required for levels in which nodes are referenced. For the root level 236 * however, signals must be emitted at all times (however the root level 237 * is always referenced when any view is attached). 238 */ 239 public template TreeModelT(TStruct) 240 { 241 /** Get the main Gtk struct */ 242 public GtkTreeModel* getTreeModelStruct(bool transferOwnership = false) 243 { 244 if (transferOwnership) 245 ownedRef = false; 246 return cast(GtkTreeModel*)getStruct(); 247 } 248 249 /** */ 250 public T getValue(T)(TreeIter iter, int column) 251 { 252 Value val; 253 getValue(iter, column, val); 254 255 return val.get!T(); 256 } 257 258 /** 259 */ 260 261 /** 262 * Creates a new `GtkTreeModel`, with @child_model as the child_model 263 * and @root as the virtual root. 264 * 265 * Params: 266 * root = A `GtkTreePath` 267 * 268 * Returns: A new `GtkTreeModel`. 269 */ 270 public TreeModelIF filterNew(TreePath root) 271 { 272 auto __p = gtk_tree_model_filter_new(getTreeModelStruct(), (root is null) ? null : root.getTreePathStruct()); 273 274 if(__p is null) 275 { 276 return null; 277 } 278 279 return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) __p, true); 280 } 281 282 alias foreac = foreach_; 283 /** 284 * Calls @func on each node in model in a depth-first fashion. 285 * 286 * If @func returns %TRUE, then the tree ceases to be walked, 287 * and gtk_tree_model_foreach() returns. 288 * 289 * Params: 290 * func = a function to be called on each row 291 * userData = user data to passed to @func 292 */ 293 public void foreach_(GtkTreeModelForeachFunc func, void* userData) 294 { 295 gtk_tree_model_foreach(getTreeModelStruct(), func, userData); 296 } 297 298 /** 299 * Returns the type of the column. 300 * 301 * Params: 302 * index = the column index 303 * 304 * Returns: the type of the column 305 */ 306 public GType getColumnType(int index) 307 { 308 return gtk_tree_model_get_column_type(getTreeModelStruct(), index); 309 } 310 311 /** 312 * Returns a set of flags supported by this interface. 313 * 314 * The flags are a bitwise combination of `GtkTreeModel`Flags. 315 * The flags supported should not change during the lifetime 316 * of the @tree_model. 317 * 318 * Returns: the flags supported by this interface 319 */ 320 public GtkTreeModelFlags getFlags() 321 { 322 return gtk_tree_model_get_flags(getTreeModelStruct()); 323 } 324 325 /** 326 * Sets @iter to a valid iterator pointing to @path. 327 * 328 * If @path does not exist, @iter is set to an invalid 329 * iterator and %FALSE is returned. 330 * 331 * Params: 332 * iter = the uninitialized `GtkTreeIter` 333 * path = the `GtkTreePath` 334 * 335 * Returns: %TRUE, if @iter was set 336 */ 337 public bool getIter(out TreeIter iter, TreePath path) 338 { 339 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 340 341 auto __p = gtk_tree_model_get_iter(getTreeModelStruct(), outiter, (path is null) ? null : path.getTreePathStruct()) != 0; 342 343 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 344 345 return __p; 346 } 347 348 /** 349 * Initializes @iter with the first iterator in the tree 350 * (the one at the path "0"). 351 * 352 * Returns %FALSE if the tree is empty, %TRUE otherwise. 353 * 354 * Params: 355 * iter = the uninitialized `GtkTreeIter` 356 * 357 * Returns: %TRUE, if @iter was set 358 */ 359 public bool getIterFirst(out TreeIter iter) 360 { 361 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 362 363 auto __p = gtk_tree_model_get_iter_first(getTreeModelStruct(), outiter) != 0; 364 365 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 366 367 return __p; 368 } 369 370 /** 371 * Sets @iter to a valid iterator pointing to @path_string, if it 372 * exists. 373 * 374 * Otherwise, @iter is left invalid and %FALSE is returned. 375 * 376 * Params: 377 * iter = an uninitialized `GtkTreeIter` 378 * pathString = a string representation of a `GtkTreePath` 379 * 380 * Returns: %TRUE, if @iter was set 381 */ 382 public bool getIterFromString(out TreeIter iter, string pathString) 383 { 384 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 385 386 auto __p = gtk_tree_model_get_iter_from_string(getTreeModelStruct(), outiter, Str.toStringz(pathString)) != 0; 387 388 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 389 390 return __p; 391 } 392 393 /** 394 * Returns the number of columns supported by @tree_model. 395 * 396 * Returns: the number of columns 397 */ 398 public int getNColumns() 399 { 400 return gtk_tree_model_get_n_columns(getTreeModelStruct()); 401 } 402 403 /** 404 * Returns a newly-created `GtkTreePath` referenced by @iter. 405 * 406 * This path should be freed with gtk_tree_path_free(). 407 * 408 * Params: 409 * iter = the `GtkTreeIter` 410 * 411 * Returns: a newly-created `GtkTreePath` 412 */ 413 public TreePath getPath(TreeIter iter) 414 { 415 auto __p = gtk_tree_model_get_path(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 416 417 if(__p is null) 418 { 419 return null; 420 } 421 422 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) __p, true); 423 } 424 425 /** 426 * Generates a string representation of the iter. 427 * 428 * This string is a “:” separated list of numbers. 429 * For example, “4:10:0:3” would be an acceptable 430 * return value for this string. 431 * 432 * Params: 433 * iter = a `GtkTreeIter` 434 * 435 * Returns: a newly-allocated string 436 */ 437 public string getStringFromIter(TreeIter iter) 438 { 439 auto retStr = gtk_tree_model_get_string_from_iter(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 440 441 scope(exit) Str.freeString(retStr); 442 return Str.toString(retStr); 443 } 444 445 /** 446 * Gets the value of one or more cells in the row referenced by @iter. 447 * 448 * See [method@Gtk.TreeModel.get], this version takes a va_list 449 * for language bindings to use. 450 * 451 * Params: 452 * iter = a row in @tree_model 453 * varArgs = va_list of column/return location pairs 454 */ 455 public void getValist(TreeIter iter, void* varArgs) 456 { 457 gtk_tree_model_get_valist(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), varArgs); 458 } 459 460 /** 461 * Initializes and sets @value to that at @column. 462 * 463 * When done with @value, g_value_unset() needs to be called 464 * to free any allocated memory. 465 * 466 * Params: 467 * iter = the `GtkTreeIter` 468 * column = the column to lookup the value at 469 * value = an empty `GValue` to set 470 */ 471 public void getValue(TreeIter iter, int column, out Value value) 472 { 473 GValue* outvalue = sliceNew!GValue(); 474 475 gtk_tree_model_get_value(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), column, outvalue); 476 477 value = ObjectG.getDObject!(Value)(outvalue, true); 478 } 479 480 /** 481 * Sets @iter to point to the first child of @parent. 482 * 483 * If @parent has no children, %FALSE is returned and @iter is 484 * set to be invalid. @parent will remain a valid node after this 485 * function has been called. 486 * 487 * If @parent is %NULL returns the first node, equivalent to 488 * `gtk_tree_model_get_iter_first (tree_model, iter);` 489 * 490 * Params: 491 * iter = the new `GtkTreeIter` to be set to the child 492 * parent = the `GtkTreeIter` 493 * 494 * Returns: %TRUE, if @iter has been set to the first child 495 */ 496 public bool iterChildren(out TreeIter iter, TreeIter parent) 497 { 498 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 499 500 auto __p = gtk_tree_model_iter_children(getTreeModelStruct(), outiter, (parent is null) ? null : parent.getTreeIterStruct()) != 0; 501 502 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 503 504 return __p; 505 } 506 507 /** 508 * Returns %TRUE if @iter has children, %FALSE otherwise. 509 * 510 * Params: 511 * iter = the `GtkTreeIter` to test for children 512 * 513 * Returns: %TRUE if @iter has children 514 */ 515 public bool iterHasChild(TreeIter iter) 516 { 517 return gtk_tree_model_iter_has_child(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0; 518 } 519 520 /** 521 * Returns the number of children that @iter has. 522 * 523 * As a special case, if @iter is %NULL, then the number 524 * of toplevel nodes is returned. 525 * 526 * Params: 527 * iter = the `GtkTreeIter` 528 * 529 * Returns: the number of children of @iter 530 */ 531 public int iterNChildren(TreeIter iter) 532 { 533 return gtk_tree_model_iter_n_children(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 534 } 535 536 /** 537 * Sets @iter to point to the node following it at the current level. 538 * 539 * If there is no next @iter, %FALSE is returned and @iter is set 540 * to be invalid. 541 * 542 * Params: 543 * iter = the `GtkTreeIter` 544 * 545 * Returns: %TRUE if @iter has been changed to the next node 546 */ 547 public bool iterNext(TreeIter iter) 548 { 549 return gtk_tree_model_iter_next(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0; 550 } 551 552 /** 553 * Sets @iter to be the child of @parent, using the given index. 554 * 555 * The first index is 0. If @n is too big, or @parent has no children, 556 * @iter is set to an invalid iterator and %FALSE is returned. @parent 557 * will remain a valid node after this function has been called. As a 558 * special case, if @parent is %NULL, then the @n-th root node 559 * is set. 560 * 561 * Params: 562 * iter = the `GtkTreeIter` to set to the nth child 563 * parent = the `GtkTreeIter` to get the child from 564 * n = the index of the desired child 565 * 566 * Returns: %TRUE, if @parent has an @n-th child 567 */ 568 public bool iterNthChild(out TreeIter iter, TreeIter parent, int n) 569 { 570 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 571 572 auto __p = gtk_tree_model_iter_nth_child(getTreeModelStruct(), outiter, (parent is null) ? null : parent.getTreeIterStruct(), n) != 0; 573 574 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 575 576 return __p; 577 } 578 579 /** 580 * Sets @iter to be the parent of @child. 581 * 582 * If @child is at the toplevel, and doesn’t have a parent, then 583 * @iter is set to an invalid iterator and %FALSE is returned. 584 * @child will remain a valid node after this function has been 585 * called. 586 * 587 * @iter will be initialized before the lookup is performed, so @child 588 * and @iter cannot point to the same memory location. 589 * 590 * Params: 591 * iter = the new `GtkTreeIter` to set to the parent 592 * child = the `GtkTreeIter` 593 * 594 * Returns: %TRUE, if @iter is set to the parent of @child 595 */ 596 public bool iterParent(out TreeIter iter, TreeIter child) 597 { 598 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 599 600 auto __p = gtk_tree_model_iter_parent(getTreeModelStruct(), outiter, (child is null) ? null : child.getTreeIterStruct()) != 0; 601 602 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 603 604 return __p; 605 } 606 607 /** 608 * Sets @iter to point to the previous node at the current level. 609 * 610 * If there is no previous @iter, %FALSE is returned and @iter is 611 * set to be invalid. 612 * 613 * Params: 614 * iter = the `GtkTreeIter` 615 * 616 * Returns: %TRUE if @iter has been changed to the previous node 617 */ 618 public bool iterPrevious(TreeIter iter) 619 { 620 return gtk_tree_model_iter_previous(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0; 621 } 622 623 /** 624 * Lets the tree ref the node. 625 * 626 * This is an optional method for models to implement. 627 * To be more specific, models may ignore this call as it exists 628 * primarily for performance reasons. 629 * 630 * This function is primarily meant as a way for views to let 631 * caching models know when nodes are being displayed (and hence, 632 * whether or not to cache that node). Being displayed means a node 633 * is in an expanded branch, regardless of whether the node is currently 634 * visible in the viewport. For example, a file-system based model 635 * would not want to keep the entire file-hierarchy in memory, 636 * just the sections that are currently being displayed by 637 * every current view. 638 * 639 * A model should be expected to be able to get an iter independent 640 * of its reffed state. 641 * 642 * Params: 643 * iter = the `GtkTreeIter` 644 */ 645 public void refNode(TreeIter iter) 646 { 647 gtk_tree_model_ref_node(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 648 } 649 650 /** 651 * Emits the ::row-changed signal on @tree_model. 652 * 653 * See [signal@Gtk.TreeModel::row-changed]. 654 * 655 * Params: 656 * path = a `GtkTreePath` pointing to the changed row 657 * iter = a valid `GtkTreeIter` pointing to the changed row 658 */ 659 public void rowChanged(TreePath path, TreeIter iter) 660 { 661 gtk_tree_model_row_changed(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 662 } 663 664 /** 665 * Emits the ::row-deleted signal on @tree_model. 666 * 667 * See [signal@Gtk.TreeModel::row-deleted]. 668 * 669 * This should be called by models after a row has been removed. 670 * The location pointed to by @path should be the location that 671 * the row previously was at. It may not be a valid location anymore. 672 * 673 * Nodes that are deleted are not unreffed, this means that any 674 * outstanding references on the deleted node should not be released. 675 * 676 * Params: 677 * path = a `GtkTreePath` pointing to the previous location of 678 * the deleted row 679 */ 680 public void rowDeleted(TreePath path) 681 { 682 gtk_tree_model_row_deleted(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct()); 683 } 684 685 /** 686 * Emits the ::row-has-child-toggled signal on @tree_model. 687 * 688 * See [signal@Gtk.TreeModel::row-has-child-toggled]. 689 * 690 * This should be called by models after the child 691 * state of a node changes. 692 * 693 * Params: 694 * path = a `GtkTreePath` pointing to the changed row 695 * iter = a valid `GtkTreeIter` pointing to the changed row 696 */ 697 public void rowHasChildToggled(TreePath path, TreeIter iter) 698 { 699 gtk_tree_model_row_has_child_toggled(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 700 } 701 702 /** 703 * Emits the ::row-inserted signal on @tree_model. 704 * 705 * See [signal@Gtk.TreeModel::row-inserted]. 706 * 707 * Params: 708 * path = a `GtkTreePath` pointing to the inserted row 709 * iter = a valid `GtkTreeIter` pointing to the inserted row 710 */ 711 public void rowInserted(TreePath path, TreeIter iter) 712 { 713 gtk_tree_model_row_inserted(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 714 } 715 716 /** 717 * Emits the ::rows-reordered signal on @tree_model. 718 * 719 * See [signal@Gtk.TreeModel::rows-reordered]. 720 * 721 * This should be called by models when their rows have been 722 * reordered. 723 * 724 * Params: 725 * path = a `GtkTreePath` pointing to the tree node whose children 726 * have been reordered 727 * iter = a valid `GtkTreeIter` pointing to the node whose children 728 * have been reordered, or %NULL if the depth of @path is 0 729 * newOrder = an array of integers mapping the current position of 730 * each child to its old position before the re-ordering, 731 * i.e. @new_order`[newpos] = oldpos` 732 */ 733 public void rowsReordered(TreePath path, TreeIter iter, int* newOrder) 734 { 735 gtk_tree_model_rows_reordered(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder); 736 } 737 738 /** 739 * Emits the ::rows-reordered signal on @tree_model. 740 * 741 * See [signal@Gtk.TreeModel::rows-reordered]. 742 * 743 * This should be called by models when their rows have been 744 * reordered. 745 * 746 * Params: 747 * path = a `GtkTreePath` pointing to the tree node whose children 748 * have been reordered 749 * iter = a valid `GtkTreeIter` pointing to the node 750 * whose children have been reordered, or %NULL if the depth 751 * of @path is 0 752 * newOrder = an array of integers 753 * mapping the current position of each child to its old 754 * position before the re-ordering, 755 * i.e. @new_order`[newpos] = oldpos` 756 */ 757 public void rowsReorderedWithLength(TreePath path, TreeIter iter, int[] newOrder) 758 { 759 gtk_tree_model_rows_reordered_with_length(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder.ptr, cast(int)newOrder.length); 760 } 761 762 /** 763 * Lets the tree unref the node. 764 * 765 * This is an optional method for models to implement. 766 * To be more specific, models may ignore this call as it exists 767 * primarily for performance reasons. For more information on what 768 * this means, see gtk_tree_model_ref_node(). 769 * 770 * Please note that nodes that are deleted are not unreffed. 771 * 772 * Params: 773 * iter = the `GtkTreeIter` 774 */ 775 public void unrefNode(TreeIter iter) 776 { 777 gtk_tree_model_unref_node(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 778 } 779 780 /** 781 * This signal is emitted when a row in the model has changed. 782 * 783 * Params: 784 * path = a `GtkTreePath` identifying the changed row 785 * iter = a valid `GtkTreeIter` pointing to the changed row 786 */ 787 gulong addOnRowChanged(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 788 { 789 return Signals.connect(this, "row-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 790 } 791 792 /** 793 * This signal is emitted when a row has been deleted. 794 * 795 * Note that no iterator is passed to the signal handler, 796 * since the row is already deleted. 797 * 798 * This should be called by models after a row has been removed. 799 * The location pointed to by @path should be the location that 800 * the row previously was at. It may not be a valid location anymore. 801 * 802 * Params: 803 * path = a `GtkTreePath` identifying the row 804 */ 805 gulong addOnRowDeleted(void delegate(TreePath, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 806 { 807 return Signals.connect(this, "row-deleted", dlg, connectFlags ^ ConnectFlags.SWAPPED); 808 } 809 810 /** 811 * This signal is emitted when a row has gotten the first child 812 * row or lost its last child row. 813 * 814 * Params: 815 * path = a `GtkTreePath` identifying the row 816 * iter = a valid `GtkTreeIter` pointing to the row 817 */ 818 gulong addOnRowHasChildToggled(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 819 { 820 return Signals.connect(this, "row-has-child-toggled", dlg, connectFlags ^ ConnectFlags.SWAPPED); 821 } 822 823 /** 824 * This signal is emitted when a new row has been inserted in 825 * the model. 826 * 827 * Note that the row may still be empty at this point, since 828 * it is a common pattern to first insert an empty row, and 829 * then fill it with the desired values. 830 * 831 * Params: 832 * path = a `GtkTreePath` identifying the new row 833 * iter = a valid `GtkTreeIter` pointing to the new row 834 */ 835 gulong addOnRowInserted(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 836 { 837 return Signals.connect(this, "row-inserted", dlg, connectFlags ^ ConnectFlags.SWAPPED); 838 } 839 840 /** 841 * This signal is emitted when the children of a node in the 842 * `GtkTreeModel` have been reordered. 843 * 844 * Note that this signal is not emitted 845 * when rows are reordered by DND, since this is implemented 846 * by removing and then reinserting the row. 847 * 848 * Params: 849 * path = a `GtkTreePath` identifying the tree node whose children 850 * have been reordered 851 * iter = a valid `GtkTreeIter` pointing to the node whose children 852 * have been reordered, or %NULL if the depth of @path is 0 853 * newOrder = an array of integers mapping the current position 854 * of each child to its old position before the re-ordering, 855 * i.e. @new_order`[newpos] = oldpos` 856 */ 857 gulong addOnRowsReordered(void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 858 { 859 return Signals.connect(this, "rows-reordered", dlg, connectFlags ^ ConnectFlags.SWAPPED); 860 } 861 }